﻿using _20160627AJAX项目学习.DAL.DataSetPostTableAdapters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace _20160627AJAX项目学习._03无刷新评论功能
{
    /// <summary>
    /// PostComment 的摘要说明
    /// </summary>
    public class PostComment : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string[] blch = { "TMD", "去死", "Fuck","脑残" };
            string message = context.Request["msg"];
            for (int i = 0; i < blch.Length; i++)
            {
                if (message.Contains(blch[i].ToString()))
                {
                    context.Response.Write("forbid");
                    return;
                }
            }
            new T_PostTableAdapter().Insert(context.Request.UserHostAddress, message, DateTime.Now);
            context.Response.Write("ok");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}